<template>
  <div id="storeAdd">
    <div class="addBanner">
   

      <div class="bannnerLi flex">
        <div class="title">名称：</div>
        <div style="width: 400px">
          <el-input
            v-model="dataList.names"
            placeholder="请输入名称"
          ></el-input>
        </div>
      </div>

      


      <div class="bannnerLi flex">
        <div class="title">账号：</div>
        <div style="width: 400px">
          <el-input
            v-model="dataList.username"
            disabled="disabled"
            placeholder="请输入账号"
          ></el-input>
        </div>
      </div>
   
      <div class="bannnerLi flex">
        <div class="title">密码：</div>
        <div style="width: 400px">
          <el-input
            v-model="dataList.password"
            show-password
            placeholder="请输入密码"
          ></el-input>
        </div>
      </div>

       <div class="bannnerLi flex">
        <div class="title">确认密码：</div>
        <div style="width: 400px">
          <el-input
            v-model="confirmPassword"
            show-password
            placeholder="请输入密码"
          ></el-input>
        </div>
      </div>

      <div class="bannnerLi flex">
        <el-button type="success" size="small" @click="submitFn()"
          >提交</el-button
        >
      </div>
    </div>

  
  </div>
</template>


<script>
import utils from "@/util/utils";

export default {
  components: {
  
  },
  data() {
    return {
      //搜索类型
      selectType: "",
      selectData: [],

      // 确认密码
      confirmPassword:"",

      // 数据
      dataList:{
          img:[]
      },

  
    };
  },
  created() {},
  mounted() {
      var user = sessionStorage.getItem("userList")
      var data = JSON.parse(user);
          data.img = utils.isJSON(data.img)?JSON.parse(data.img):data.img;
          data.img =  Array.isArray( data.img)?data.img:[];
      this.dataList = data;
  },

  methods: {
    
 
    // 提交提交
    submitFn: function (res) {
      var data = this.dataList;
      var that = this;
      if (!data.names) {
        that.$message.error("请输入名称");
        return;
      }else if (!data.password) {
        that.$message.error("请输入密码");
        return;
      }else if (!this.confirmPassword) {
        that.$message.error("请输入确认密码");
        return;
      }else if(this.confirmPassword != data.password){
        that.$message.error("密码不一致");
        return;
      }
      data = {
        sid:data.id,
        names:data.names,
        password:data.password,
      }
      this.totalSubmitFn(data);
    },

    //提交
    totalSubmitFn: function (data) {
      var urls = this.$api.api.editPass.editPass;
        this.$https(urls,data, "POST").then((res) => {
          if (res.data.code == 200) {
            this.$message.success("操作成功");
            sessionStorage.removeItem("userList");
            sessionStorage.removeItem("isLogin");
            this.$router.push({path:'/'});
          } else {
            this.$message.error(res.data.msg);
          }
        });
    },

 


  },
};
</script>

<style scoped lang="less">
#storeAdd {
  width: 100%;

  .el-select {
    width: 400px;
  }

  // 轮播图列表
  .bannerBox {
    width: 100%;
    border: 2px solid #ccc;
    padding: 5px;
    overflow-x: scroll;

    .banner {
      width: 160px;
      position: relative;
      margin-right: 10px;

      .el-upload {
        width: 160px;
        display: block;

        img {
          width:160px;
          height: 110px;
          border: 2px dashed #dedede;
          line-height: 120px;
          text-align: center;
          font-size: 28px;
          color: #999;
        }
      }

      .el-icon-error {
        position: absolute;
        top: 5px;
        right: 5px;
        font-size: 25px;
        color: red;
      }
    }

    .addImg {
      width: 120px;
      height: 115px;
      line-height: 115px;
      border: 2px dashed #ccc;
      padding: 0;
      text-align: center;
      font-size: 30px;
      color: #777;

      .el-icon-error {
        width: 115px;
        height: 115px;
      }
    }
  }

  .bannerImg {
    width: 180px;
    height: 70px;
    margin: auto;

    img {
      width: 100%;
      height: 100%;
    }
  }

  .bannerList {
    width: 100%;
  }

  // 新增图片
  .addBanner {
    width: 100%;
    padding: 5px 20px;
    box-sizing: border-box;
  }

  .bannnerLi {
    width: 100%;
    margin-bottom: 30px;

    .title {
      width: 110px;
      flex-shrink: 0;
    }
  }
}
</style>